package com.woniuxy.educationplatform.controller;

import com.woniuxy.educationplatform.bean.SchoolBean;
import com.woniuxy.educationplatform.bean.StatusBean;
import com.woniuxy.educationplatform.service.ISchoolService;
import com.woniuxy.educationplatform.service.IStatusService;
import com.woniuxy.educationplatform.util.ResultUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/school")
public class SchoolController {
    @Resource
    private ISchoolService schoolService;

    @RequestMapping("/findAll")
    public ResultUtil findAllSchool(){
        List<SchoolBean> schoolBeans = schoolService.selectAllSchool();
        ResultUtil<List<SchoolBean>> resultUtil = new ResultUtil<>();
        if (schoolBeans == null) {
            resultUtil.setCode(ResultUtil.ERROR).setMessage("出错了…… 没有找到");
        }else {
            resultUtil.setCode(ResultUtil.SUCCESS).setMessage("请求成功").setData(schoolBeans);
        }
        return resultUtil;
    }
}
